package com.burpee.dao;

import java.util.List;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.burpee.ui.Statistics;

@Repository(value="statisticsDao")
public class StatisticsDaoImpl implements StatisticsDao {
	

	SqlSessionTemplate sqlSessionTemplate;

	@Autowired
	public void setSqlSessionTemplate(SqlSessionFactory sqlSessionFactory) {
		this.sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory);
	}

	public List<Statistics> list() {
		List<Statistics> list = null;
		
		try {
			list = sqlSessionTemplate.selectList("statisticslist");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return list;
	}

	public Statistics view(String memberId) {
		 Statistics statistics = new Statistics();
		 
		 try {
			statistics = sqlSessionTemplate.selectOne("statisticsview", memberId);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		 
		return statistics;
	}

	public int add(Statistics statistics) {
		
		int result = 0;
		try {
			result = (int)sqlSessionTemplate.insert("statisticsadd",statistics);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return result;
	}

//	public int modify(Statistics statistics) {
//		int result = 0;
//		try {
//			result = (int)sqlSessionTemplate.update("statisticsmodify", statistics);
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		
//		return result;
//	}
//
//	public int remove(String memberId) {
//		
//		int result = 0;
//		try {
//			result = (int)sqlSessionTemplate.delete("statisticsremove",memberId);
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		
//		return result;
//	}

}
